package com.ranjiaqi.output;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * @ClassName TestOutPutStreamException
 * @Description TODO
 * @Author hp
 * @Date 2021/7/1 11:06
 * @Version 1.0
 **/
public class TestOutPutStreamException {
    public static void main(String[] args) {
        OutputStream outputStream = null;
        try {
            outputStream = new FileOutputStream("s:/1.text");
            outputStream.write('a');
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            try {
                //因为有可能会发生空指针异常所以需要进行判断
                if(outputStream !=null)
                    outputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
